package com.tensquare.jwt;

import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;

import java.util.Date;

public class CreateJwt2 {
    public static void main(String[] args) {
        //将过期时间设置一分钟
        long now =System.currentTimeMillis();//当前时间
        long exp = now +1000*60;

        JwtBuilder jwtBuilder = Jwts.builder().setId("888")
                .setSubject("小白")
                .setIssuedAt(new Date())
                .signWith(SignatureAlgorithm.HS256, "itcast")
                .setExpiration(new Date(exp));
        System.out.println(jwtBuilder.compact());


    }
}
